package com.eightbears.beboy.base.view.popupwindow;

import android.app.Activity;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.AnimationSet;
import android.widget.TextView;

import com.eightbears.beboy.R;
import com.eightbears.beboy.adapter.AgencyCityAdapter;
import com.eightbears.beboy.base.view.basepopu.BasePopupWindow;

/**
 * Created by Bao on 2017/5/3.
 * 代理城市
 */

public class AgencyCityPopup extends BasePopupWindow implements View.OnClickListener {

    private View popupView;
    private AgencyCityAdapter adapter;

    public AgencyCityPopup(Activity context) {
        super(context);
        bindEvent();
    }

    @Override
    public Animation getAnimation() {
        return getTranslateAnimation(250 * 2, 0, 300);
    }

    @Override
    public AnimationSet getAnimationSet() {
        return null;
    }

    @Override
    public View getInputView() {
        return null;
    }

    @Override
    public View getDismissView() {
        return popupView.findViewById(R.id.click_to_dismiss);
    }

    @Override
    public View getPopupView() {
        popupView = LayoutInflater.from(mContext).inflate(R.layout.view_agencycity_popup, null);
        return popupView;
    }

    @Override
    public View getAnimaView() {
        return popupView.findViewById(R.id.popup_anima);
    }

    public void setTitle(String title) {
        ((TextView) popupView.findViewById(R.id.tv_pay_title)).setText(title);
    }

    public void setListViewAdapter(AgencyCityAdapter adapter) {
        this.adapter = adapter;
        ((RecyclerView) popupView.findViewById(R.id.rv_list)).setAdapter((RecyclerView.Adapter) adapter);
        ((RecyclerView) popupView.findViewById(R.id.rv_list)).setLayoutManager(new LinearLayoutManager(mContext));
    }

    public AgencyCityAdapter getAdapter() {
        return adapter;
    }

    private void bindEvent() {
        if (popupView != null) {
            popupView.findViewById(R.id.ll_back).setOnClickListener(this);
        }
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.ll_back:
                dismiss();
                break;
        }
    }
}
